<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登陆</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        html,
        body {
            height: 100%;
        }

        body {
            background: url(./bg.jpeg) no-repeat;
        }

        .box {
            width: 400px;
            height: 400px;
            margin: 200px auto;
        }

        .box .top {
            height: 50px;
            border-radius: 10px 10px 0 0;
            background-color: lightskyblue;
            color: white;
            text-align: center;
            line-height: 50px;
        }

        .box .bottom {
            box-sizing: border-box;
            height: 350px;
            border-radius: 0 0 10px 10px;
            background-color: aliceblue;
            padding: 40px 20px;
        }

        .box .bottom input {
            width: 100%;
            height: 30px;
            margin-bottom: 20px;
            outline: none;
        }

        .box .bottom .box1 {
            display: flex;
            justify-content: space-between;
        }

        .box .bottom .box1 a {
            display: inline-block;
            color: gray;
            text-decoration: none;
            cursor: pointer;
        }

        .box .bottom button {
            padding: 10px 20px;
            margin: 30px 0 0 150px;
            background-color: lightgreen;
            border: 0;
            border-radius: 5px;
            color: white;
            cursor: pointer;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="top">欢迎登陆后台管理系统</div>
        <div class="bottom">
            <input type="text" placeholder="输入手机号">
            <br>
            <input type="password" placeholder="输入密码">
            <div class="box1">
                <a href="./03注册.html">去注册</a>
                <a>忘记密码</a>
            </div>
            <button>登陆</button>
        </div>
    </div>
</body>

</html>
<script src="./axios.min.js"></script>
<script>
    var inps = document.querySelectorAll('.bottom input')
    var btn = document.querySelector('.bottom button')
    btn.onclick = function () {
        axios.post('/user/login', { phone: inps[0].value, pass: inps[1].value }).then((res) => {
            if (res.data.code == 200) {
                localStorage.setItem('userinfo', JSON.stringify(res.data.userinfo))
                alert('登陆成功')
                location.href='./02首页.html'
            }else{
                alert('登陆失败')
            }
        })
    }
</script>